<?php

namespace cf\api\cookie;

require_once dirname(__FILE__).'/../cookie.php';

/**
	@param $expireMin  expire time in minutes, also can be 'never'
*/
function set($name, $expireMin=0, $params=array(), $path='/')
{
	if ($expireMin == 'never') {
		$expireMin = 60*24*365*10;
	}
	$cookie = new \cf\Cookie($name, $expireMin, $path);
	foreach ($params as $nm => $val) {
		$cookie->setParam($nm, $val);
	}
	$cookie->set();
}

function get($name, $param=false)
{
	$cookie = \cf\Cookie::retrieve($name);
	if ($cookie) {
		if ($param) {
			return $cookie->getParam($param);
		}
		return $cookie->getParams();
	}
	return false;
}

function del($name)
{
	$cookie = \cf\Cookie::retrieve($name);
	if ($cookie) {
		$cookie->del();
	}
}